package com.aaa.java11.test.impl;

import com.aaa.java11.test.Calc;
import org.apache.log4j.Logger;

import java.util.Date;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/14 14:45
 * @description：计算器的实现类
 * @modified By：
 * @version: 1.0
 */
public class CalcImpl  implements Calc {
    /**
     *     //实例化log对象
     */
    Logger logger = Logger.getLogger(CalcImpl.class);
    @Override
    public int add(int a, int b) {
        logger.info(new Date());
        logger.info(new Date());
        logger.info(new Date());
        logger.info(new Date());
        logger.info(new Date());
        logger.info(new Date());
        logger.info(new Date());
        return a+b;
    }

    @Override
    public int subtract(int a, int b) {
        return a-b;
    }

    @Override
    public int multiply(int a, int b) {
        return a*b;
    }

    @Override
    public int divide(int a, int b) {
        int c=0;
        try {
            c=a/b;
        }catch (ArithmeticException e){
            logger.error("除数不能为零");
        }

        return c;
    }
}
